<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="/WEB-INF/mytag.tld" prefix="f"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";

	int pageNum = (Integer) request.getAttribute("pageNum");
	int allpage = (Integer) request.getAttribute("allpage");
	int allCounts = (Integer) request.getAttribute("allCounts");
	List allJok = (List) request.getAttribute("allJok");
	int count = (Integer) request.getAttribute("count");
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<base href="<%=basePath%>">

		<title>My JSP 'jokShow.jsp' starting page</title>
		<META http-equiv=Content-Type content="text/html; charset=gb2312">
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="This is my page">
		<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
		<script language="javascript">
function getXmlHttp(){ 
    var http_request = false; 
    if (window.XMLHttpRequest){ 
        http_request = new XMLHttpRequest(); 
        if (http_request.overrideMimeType){ 
            http_request.overrideMimeType('text/xml'); 
	} 
   }else if (window.ActiveXObject){ 
        try{ 
            http_request = new ActiveXObject("Msxml2.XMLHTTP"); 
        } catch (e){ 
            try{ 
                http_request = new ActiveXObject("Microsoft.XMLHTTP"); 
            }catch (e) {
            } 
        } 
    } 
    if (!http_request){ 
        alert("系统忙、请稍后再试!"); 
        return false; 
    } 
    return http_request; 
} 

function resultDing(){ 
    if(req.readyState == 4 && req.status == 200){
		var strs = new Array(2); //定义一数组
		strs = req.responseText.toString().split("_"); //字符分割     
				
    	if(req.responseText.toString() != "flase"){
    		document.getElementById("div_ding_" + strs[0]).disabled = true;
    		document.getElementById("div_cai_" + strs[0]).disabled = true;
    		document.getElementById("but_ding_" + strs[0]).disabled = true;
    		document.getElementById("but_cai_" + strs[0]).disabled = true;
    		    		
	       	document.getElementById("div_ding_" + strs[0]).innerHTML = strs[1];
    	}else{
    		alert("系统忙、请稍后!");
    	}
    }     
} 

function resultCai(){ 
    if(req.readyState == 4 && req.status == 200){
    	var strs = new Array(2); //定义一数组
		strs = req.responseText.toString().split("_"); //字符分割 
		
    	if(req.responseText.toString() != "flase"){
    		document.getElementById("div_ding_" + strs[0]).disabled = true;
    		document.getElementById("div_cai_" + strs[0]).disabled = true;    		
    		document.getElementById("but_ding_" + strs[0]).disabled = true;
    		document.getElementById("but_cai_" + strs[0]).disabled = true;
    		
	       	document.getElementById("div_cai_" + strs[0]).innerHTML = strs[1];
    	}else{
    		alert("系统忙、请稍后!");
    	}
    }     
} 

function operateDing(id){	
	var ul="AjaxOperateServlet?flag=1&id=" + id;     
	req = getXmlHttp(); 
	req.onreadystatechange = resultDing; 
	req.open("GET",ul,true); 
	req.setRequestHeader('If-Modified-Since', '0'); 
	req.send(null); 
}

function operateCai(id){	
	var ul="AjaxOperateServlet?flag=-1&id=" + id;     
	req = getXmlHttp(); 
	req.onreadystatechange = resultCai; 
	req.open("GET",ul,true); 
	req.setRequestHeader('If-Modified-Since', '0'); 
	req.send(null); 
}

function op_ping(id){
	var flag = document.getElementById("div_ping_" + id).style.display;
	if(flag == "none"){
		document.getElementById("div_ping_" + id).style.display = "";
	}else{
		document.getElementById("div_ping_" + id).style.display = "none";
	}
}

function checkNull(id){
	var value = document.getElementById("con_commont_" + id).value;
	if(value == ""){
		alert("亲、说点啥再提交呗!");
		return false;
	}else{
		document.location.href = "";
	}
}
</script>
<style>
.btn_ding {
	background: url(/img/ding.gif) center no-repeat;
	border: 0px;
	width: 48;
	height: 24;
}

.btn_cai {
	background: url(/img/cai.gif) center no-repeat;
	border: 0px;
	width: 48;
	height: 24;
}
</style>
<style>
a:link {text-decoration: none;}
a:visited {text-decoration: none;}
a:active {text-decoration: none;}
a:hover {text-decoration: none;}
</style>
	</head>
	<body>		
		<table height="40" border="0" cellspacing="5" cellpadding="0">
			<tr>
				<td>
					<A href="<%=basePath %>index.jsp">首页</A>&nbsp;>&nbsp;>
					<A>白领生活</A>
				</td>
				<td></td>
				<td></td>
			</tr>
		</table>
		<center>
		<div style="width: 800px; margin: 0 auto;">
			<table border="0" cellspacing="5" cellpadding="0">
				<tr>
					<td></td>
					<td></td>
					<td><a href="/doJok.do?opers2=showJoks">查看最新动态</a></td>
				</tr>
			</table>
			<table border="0" cellspacing="5" cellpadding="0">
				<tr>
					<td></td>
					<td></td>
					<td></td>
				</tr>
			</table>			
			<table cellSpacing=0 cellPadding=1 width="800" border=0>
				<tr>
					<td align="left" colspan="2">
						<HR style="FILTER: progid:DXImageTransform.Microsoft.Shadow(color:#987cb9,direction:145,strength:15)" width="100%" color=#987cb9 SIZE=1>
					</td>
				</tr>
				<c:forEach var="jok" items="<%=allJok%>">
					<tr>
						<td align="left" colspan="2">
							&nbsp;
						</td>
					</tr>
					<tr>
						<td align="left">
							${jok.title}&nbsp;「 来源于网络 」
						</td>
						<td align="center">
							${jok.subDate}
						</td>
					</tr>
					<tr>
						<td align="left" colspan="2">
							&nbsp;
						</td>
					</tr>
					<tr>
						<td align="left" colspan="2">
							&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
							${jok.content}
						</td>
					</tr>
					<tr>
						<td align="left" colspan="2">
							&nbsp;
						</td>
					</tr>
					<tr>
						<td align="left">
							&nbsp;&nbsp;
							<img src="img/ping.bmp" onclick="javascript:op_ping('${jok.id}');"/>「&nbsp;${jok.jokComCounts}&nbsp;」
						</td>
						<td align="center">
							<input type="button" class="btn_ding" id="but_ding_${jok.id}"
								onclick="javascript:operateDing('${jok.id}');" />
							(
							<span id="div_ding_${jok.id}">${jok.ding}</span>)
							<input type="button" class="btn_cai" id="but_cai_${jok.id}"
								onclick="javascript:operateCai('${jok.id}');" />
							(
							<span id="div_cai_${jok.id}">${jok.cai}</span>)
						</td>
					</tr>
					
					<tr id="div_ping_${jok.id}" style="display:none;">
						<td align="left" colspan="2">							
							<HR style="border:3 double #987cb9" width="100%" color=#987cb9 SIZE=3>														
							<form action="/doJok.do?opers2=subComment&jokId=${jok.id}" method="post" id="subComment" name="subComment">
								<table cellSpacing=0 cellPadding=1 width="600" border=0>
								<c:forEach var="com" items="${jok.commentSet}">
									<tr>
										<td align="left" colspan="2">
											&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
											<font size="2">${com.content}</font>
										</td>
									</tr>
									<tr>
										<td align="right" colspan="2">
											<font size="2">${com.subDate}</font>
										</td>
									</tr>
									<tr>
										<td colspan="2">
											<HR style="border: 1 dashed #987cb9" width="100%" color=#987cb9 SIZE=1>
										</td>
									</tr>																								
								</c:forEach>
								<tr>
									<td colspan="2">
										<font size="2">我来说：</font>
										<textarea rows="3" cols="30" id="con_commont_${jok.id}" name="con_commont_${jok.id}" onblur="this.style.color='#999';if(this.value=='') this.value='发表下你的观点...';" 
										onkeyup="if(event.keyCode==13){doSearch();}" onfocus="this.style.color='#000';if(this.value=='发表下你的观点...') this.value='';">发表下你的观点...</textarea>
										<input type="submit" id="sub_commont" value="提  交"/><font size="2" color="red">(提示：评论需审核才能显示)</font>
									</td>
								</tr>									
							</table>
							</form>							
						</td>
					</tr>
					<tr>
						<td align="left" colspan="2">
							<HR style="FILTER: progid:DXImageTransform.Microsoft.Shadow(color:#987cb9,direction:145,strength:15)" width="100%" color=#987cb9 SIZE=1>
						</td>
					</tr>
				</c:forEach>
				<tr>
					<td align="left" colspan="2">
						&nbsp;
					</td>
				</tr>
				<tr>
					<td align="center" colspan="2">
						<f:fenye className="doJok" para="opers2" functionName="showJoks"  count="<%=count %>"
							pageNum="<%=pageNum%>" totalPage="<%=allpage %>" allCounts="<%=allCounts %>"/>
					</td>
				</tr>
				<tr>
					<td align="left" colspan="2">
						&nbsp;
					</td>
				</tr>
			</table>
			<table align="center" width=800 height=25 bgcolor=#fbfbfb border=0
				cellspacing=0 cellspading=2>
				<tr>
					<td style="color: #424242; padding-right: 10px; font-size: 12px;">
						管理员QQ：
						<a target=blank href=http://wpa.qq.com/msgrd?V=1&Uin=457429114&Site=http://www.17113.cc&Menu=yes>
						<img border="0" SRC=http://wpa.qq.com/pa?p=1:457429114:16 alt="点击这里给我发消息"></a>
					</td>
				</tr>
			</table>
		</div>
		</center>		
	</body>
</html>
